import streamlit as st
import auth

def render():
    """渲染登录界面"""
    # 初始化认证状态
    auth.init_auth()
    
    # 如果已登录，显示登出按钮
    if st.session_state.logged_in:
        col1, col2, col3 = st.columns([1, 1, 1])
        
        with col1:
            st.write(f"当前用户: **{st.session_state.user['username']}**")
        
        with col2:
            user_type = "管理员" if st.session_state.user['is_admin'] else "普通用户"
            st.write(f"用户类型: **{user_type}**")
        
        with col3:
            if st.button("登出"):
                auth.logout()
                st.rerun()
        
        return True
    else:
        # 显示登录界面
        auth.login_page()
        return False 